<template>
  <div class="admin-layout">
    <el-container>
      <!-- 侧边栏 -->
      <el-aside width="240px" class="sidebar">
        <div class="logo">
          <h3>视频管理系统</h3>
        </div>
        <el-menu
          :default-active="activeMenu"
          class="el-menu-vertical-dark"
          router
        >
          <el-menu-item index="/dashboard">
            <el-icon><Document /></el-icon>
            <span>仪表盘</span>
          </el-menu-item>
          <el-menu-item index="/categories">
            <el-icon><Menu /></el-icon>
            <span>视频类别管理</span>
          </el-menu-item>
          <el-menu-item index="/video-types">
            <el-icon><VideoCamera /></el-icon>
            <span>视频类型管理</span>
          </el-menu-item>
          <el-menu-item index="/videos">
            <el-icon><VideoPlay /></el-icon>
            <span>视频管理</span>
          </el-menu-item>
          <el-menu-item index="/comments">
            <el-icon><ChatRound /></el-icon>
            <span>评论管理</span>
          </el-menu-item>
          <el-menu-item index="/users">
            <el-icon><User /></el-icon>
            <span>用户管理</span>
          </el-menu-item>
          <el-menu-item index="/settings">
            <el-icon><Setting /></el-icon>
            <span>系统设置</span>
          </el-menu-item>
        </el-menu>
      </el-aside>

      <!-- 主内容区 -->
      <el-container>
        <!-- 顶部导航 -->
        <el-header class="header">
          <div class="header-left">
            <span>管理员控制台</span>
          </div>
          <div class="header-right">
            <span class="user-info">{{ userInfo.username }}</span>
            <el-button type="text" @click="handleLogout">
              <el-icon><SwitchButton /></el-icon>
              退出登录
            </el-button>
          </div>
        </el-header>

        <!-- 内容区 -->
        <el-main class="main-content">
          <div class="management-content">
            <h2>评论管理</h2>
            <div class="section-title">管理平台上的评论内容</div>
            
            <div class="search-bar">
              <el-input
                v-model="searchQuery"
                placeholder="搜索评论内容或用户名"
                prefix-icon="el-icon-search"
                style="width: 400px;"
              ></el-input>
              <el-button type="primary" @click="handleBatchDelete">
                <el-icon><Delete /></el-icon>
                批量删除
              </el-button>
            </div>

            <div class="empty-state">
              <el-empty description="评论管理功能开发中"></el-empty>
            </div>
          </div>
        </el-main>
      </el-container>
    </el-container>
  </div>
</template>

<script setup lang="ts">
import { ref, computed, onMounted } from 'vue';
import { useRouter } from 'vue-router';
import { ElMessage } from 'element-plus';
import { Document, User, Menu, VideoPlay, ChatRound, Setting, SwitchButton, Delete } from '@element-plus/icons-vue';

const router = useRouter();
const userInfo = ref({ username: '', nickname: '', role: '' });
const searchQuery = ref('');

const activeMenu = computed(() => {
  return window.location.pathname;
});

const initData = () => {
  const userStr = localStorage.getItem('user');
  if (userStr) {
    userInfo.value = JSON.parse(userStr);
  }
};

const handleLogout = () => {
  localStorage.removeItem('token');
  localStorage.removeItem('user');
  ElMessage.success('退出登录成功');
  router.push('/login');
};

const handleBatchDelete = () => {
  ElMessage.info('批量删除功能开发中');
};

onMounted(() => {
  initData();
});
</script>

<style scoped>
.admin-layout {
  height: 100vh;
  background-color: #1a1a1a;
}

.sidebar {
  background-color: #2a2a2a;
  height: 100vh;
}

.logo {
  padding: 20px;
  text-align: center;
  border-bottom: 1px solid #3a3a3a;
}

.logo h3 {
  color: #ffffff;
  margin: 0;
}

.el-menu-vertical-dark {
  background-color: transparent;
  border-right: none;
}

.el-menu-item {
  color: #cccccc;
  margin: 0 10px;
  border-radius: 4px;
}

.el-menu-item:hover {
  background-color: #3a3a3a;
  color: #ffffff;
}

.el-menu-item.is-active {
  background-color: #409eff;
  color: #ffffff;
}

.header {
  background-color: #2a2a2a;
  color: #ffffff;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 20px;
  border-bottom: 1px solid #3a3a3a;
}

.user-info {
  margin-right: 20px;
  color: #cccccc;
}

.main-content {
  background-color: #1a1a1a;
  padding: 20px;
  overflow: auto;
}

.management-content h2 {
  color: #ffffff;
  margin-bottom: 5px;
}

.section-title {
  color: #999999;
  margin-bottom: 20px;
  font-size: 14px;
}

.search-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.empty-state {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 400px;
  background-color: #2a2a2a;
  border-radius: 8px;
}

.el-empty {
  color: #999999;
}
</style>